# def normalize_heading_to_level1(line):
#     stripped = line.lstrip()
#     if stripped.startswith('#'):
#         level = len(stripped) - len(stripped.lstrip('#'))
#         content = stripped[level:].strip()
#         return f"# {content}"
#     return line  # 非标题行不变
#
#
# with open("D:\\hbyt\\AI智能投标\\能力组件-附件\\百硕_资质证书_v3.0_2402.md", 'r', encoding='utf-8') as f:
#     lines = [line for line in f]
# # 示例用法
# line = "####### 百硕资质荣誉"
# new_line = normalize_heading_to_level1(line)
# print(new_line)  # 输出: # 百硕资质荣誉
from win32print import PRINTER_ENUM_NETWORK


# def count_heading_level(line):
#     stripped = line.lstrip()
#     count = 0
#     for char in stripped:
#         if char == '#':
#             count += 1
#         else:
#             break
#     return count
#
# def reduce_one_heading_hash(line):
#     stripped = line.lstrip()
#     count = 0
#     for char in stripped:
#         if char == '#':
#             count += 1
#         else:
#             break
#     # 保证至少保留一个 #
#     new_count = max(1, count - 1)
#     content = stripped[count:].lstrip()
#     return f"{'#' * new_count} {content}"
#
# def read_first_line(md_path):
#     with open(md_path, 'r', encoding='utf-8') as f:
#         first_line = f.read()
#         for l in first_line:
#             stripped = l.lstrip()
#             if stripped.startswith('#'):
#                 if count_heading_level(first_line)==1 or count_heading_level(first_line)==0:
#                     return "全部返回"
#                 else:
#                     cont=[]
#                     with open(md_path, 'r', encoding='utf-8') as f:
#                         for line in f:
#                             stripped = line.lstrip()
#                             if stripped.startswith('#'):
#                                 new_line = reduce_one_heading_hash(line)
#                                 cont.append(new_line)
#                             else:
#                                 cont.append(line)
#                     c=''.join(cont)
#                     with open(md_path, 'w', encoding='utf-8') as f:
#                         f.write(c)
#                     with open(md_path, 'r', encoding='utf-8') as f:
#                         content=f.read()
#                     return content
# # 示例用法
# md_file = "D:\\hbyt\\AI智能投标\\能力组件-附件\\测试1.md"
# first = read_first_line(md_file)
# print(first)


# from docx import Document
# from docx.shared import Inches
# from docx.oxml.ns import qn
#
# doc = Document()
#
# # 添加一个表格（2行2列）
# table = doc.add_table(rows=2, cols=2)
#
# # 设置为实线边框样式（推荐样式名）
# try:
#     table.style = 'Table Grid'  # 实线框样式
# except KeyError:
#     table.style = 'TableNormal'  # 备选样式（可能不带框）
#
# # 填充内容
# table.cell(0, 0).text = "标题1"
# table.cell(0, 1).text = "标题2"
# table.cell(1, 0).text = "数据1"
# table.cell(1, 1).text = "数据2"
#
# # 保存
# doc.save("实线表格示例.docx")


import re

text = "2.2.2 相关方案"

# 提取第一个数字（以数字开头）
match = re.match(r'^(\d+)', text)
if match:
    first_number = match.group(1)
else:
    print("未找到数字")
print("第一个数字是：", first_number)


